<template>
<!-- 育儿知识 -->
<div>
  <div class="submit-box head-line body-cont">
    <div class="card-shadow">
      <div class="weui-cell area-box">
        <view class="weui-cell__hd">
          <view class="weui-label">姓名</view>
        </view>
        <view class="weui-cell__bd">
          <input maxlength="50" class="flex-box" name="knowledgeUsername" v-model="knowledgeUsername" type="text" placeholder="请填写姓名">
        </view>
      </div>
    </div>
    <div class="card-shadow">
      <div class="weui-cell area-box">
        <view class="weui-cell__hd">
          <view class="weui-label">联系电话</view>
        </view>
        <view class="weui-cell__bd">
          <input maxlength="50" class="flex-box" name="phone" v-model="phone" type="number" placeholder="请填写联系电话">
        </view>
      </div>
    </div>
  </div>
  <div class="btn-box">
    <button class="btn-full" :loading="isSubmit" @tap="submit" >确定报名</button>
  </div>
</div>
</template>
<script>
import saveOrder from '@/interface/order/saveOrder'
import valid from '@/utils/valid'
import {serviceTypeData} from '@/config'
export default {
  components: { },
  data () {
    return {
      isSubmit: false,
      knowledgeUsername: '',
      phone: ''
    }
  },
  computed: {
  },
  methods: {
    submit () {
      if (!this.knowledgeUsername) {
        this.dialog.showToast('请填写姓名')
        return false
      }
      if (!valid.isPhone(this.phone)) { return }
      this.isSubmit = true
      saveOrder({
        serviceType: serviceTypeData.yezs,
        phone: this.phone,
        knowledgeUsername: this.knowledgeUsername
      }).then(v => {
        this.goStatusPage('success')
      }).catch(msg => this.dialog.showToast(msg || '保存失败'))
        .finally(() => { this.isSubmit = true })
    }
  },
  beforeMount () {
    if (!this.cookie.isLogin()) {
      wx.navigateTo({ url: '/pages/login/main' })
    }
  },
  mounted () {

  }
}
</script>
<style lang="less">
page {
  background-color: #f9f9f9;
}
.body-cont {
  padding-top: 30px;
}
</style>